package io.springboot.jpa.examples.springbootjpaexamples.web.controller;

import io.springboot.jpa.examples.springbootjpaexamples.config.shiro.JwtUtils;
import io.springboot.jpa.examples.springbootjpaexamples.web.ResultMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yzc
 * @description
 * @date 2018/9/7
 */
@RequestMapping("/auth")
@RestController
public class AuthenticationController extends BaseController {


    @RequestMapping
    public Object auth(HttpServletRequest request) {
        String username = request.getParameter("name");
        String password = request.getParameter("pwd");
        String[] roles = new String[1];
        roles[0] = "admin";
        String[] permissions = new String[1];
        permissions[0] = "users";
        return new ResultMap().ok().data(JwtUtils.createToken(username, roles, permissions));
    }
}
